<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHCi.Signals</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHCi.Signals.html#installSignalHandlers"><span class="hs-identifier">installSignalHandlers</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-comment">-- See note [Why do we import Prelude here?]</span><span>
</span><span id="line-5"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Concurrent.html#"><span class="hs-identifier">Control.Concurrent</span></a></span><span>
</span><span id="line-6"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span>
</span><span id="line-7"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.Mem.Weak.html#"><span class="hs-identifier">System.Mem.Weak</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Weak.html#deRefWeak"><span class="hs-identifier">deRefWeak</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">

#if !defined(mingw32_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Posix.Signals</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.ConsoleHandler.html#"><span class="hs-identifier">GHC.ConsoleHandler</span></a></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- | Install standard signal handlers for catching ^C, which just throw an</span><span>
</span><span id="line-18"></span><span class="hs-comment">--   exception in the target thread.  The current target thread is the</span><span>
</span><span id="line-19"></span><span class="hs-comment">--   thread at the head of the list in the MVar passed to</span><span>
</span><span id="line-20"></span><span class="hs-comment">--   installSignalHandlers.</span><span>
</span><span id="line-21"></span><span class="annot"><a href="GHCi.Signals.html#installSignalHandlers"><span class="hs-identifier hs-type">installSignalHandlers</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span id="installSignalHandlers"><span class="annot"><span class="annottext">installSignalHandlers :: IO ()
</span><a href="GHCi.Signals.html#installSignalHandlers"><span class="hs-identifier hs-var hs-var">installSignalHandlers</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-23"></span><span>  </span><span id="local-6989586621679087912"><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679087912"><span class="hs-identifier hs-var">main_thread</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO ThreadId
</span><a href="../../base/src/GHC.Conc.Sync.html#myThreadId"><span class="hs-identifier hs-var">myThreadId</span></a></span><span>
</span><span id="line-24"></span><span>  </span><span id="local-6989586621679087910"><span class="annot"><span class="annottext">Weak ThreadId
</span><a href="#local-6989586621679087910"><span class="hs-identifier hs-var">wtid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ThreadId -&gt; IO (Weak ThreadId)
</span><a href="../../base/src/GHC.Conc.Sync.html#mkWeakThreadId"><span class="hs-identifier hs-var">mkWeakThreadId</span></a></span><span> </span><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679087912"><span class="hs-identifier hs-var">main_thread</span></a></span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679087904"><span class="annot"><span class="annottext">interrupt :: IO ()
</span><a href="#local-6989586621679087904"><span class="hs-identifier hs-var hs-var">interrupt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-27"></span><span>        </span><span id="local-6989586621679087903"><span class="annot"><span class="annottext">Maybe ThreadId
</span><a href="#local-6989586621679087903"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Weak ThreadId -&gt; IO (Maybe ThreadId)
forall v. Weak v -&gt; IO (Maybe v)
</span><a href="../../base/src/GHC.Weak.html#deRefWeak"><span class="hs-identifier hs-var">deRefWeak</span></a></span><span> </span><span class="annot"><span class="annottext">Weak ThreadId
</span><a href="#local-6989586621679087910"><span class="hs-identifier hs-var">wtid</span></a></span><span>
</span><span id="line-28"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe ThreadId
</span><a href="#local-6989586621679087903"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-29"></span><span>          </span><span class="annot"><span class="annottext">Maybe ThreadId
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679087902"><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679087902"><span class="hs-identifier hs-var">t</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ThreadId -&gt; AsyncException -&gt; IO ()
forall e. Exception e =&gt; ThreadId -&gt; e -&gt; IO ()
</span><a href="../../base/src/GHC.Conc.Sync.html#throwTo"><span class="hs-identifier hs-var">throwTo</span></a></span><span> </span><span class="annot"><span class="annottext">ThreadId
</span><a href="#local-6989586621679087902"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">AsyncException
</span><a href="../../base/src/GHC.IO.Exception.html#UserInterrupt"><span class="hs-identifier hs-var">UserInterrupt</span></a></span><span class="hs-cpp">

#if !defined(mingw32_HOST_OS)
</span><span>  </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">installHandler</span><span> </span><span class="hs-identifier">sigQUIT</span><span>  </span><span class="hs-special">(</span><span class="hs-identifier">Catch</span><span> </span><span class="hs-identifier">interrupt</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">Nothing</span><span>
</span><span id="line-34"></span><span>  </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">installHandler</span><span> </span><span class="hs-identifier">sigINT</span><span>   </span><span class="hs-special">(</span><span class="hs-identifier">Catch</span><span> </span><span class="hs-identifier">interrupt</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">Nothing</span><span class="hs-cpp">
#else
</span><span>  </span><span class="hs-comment">-- GHC 6.3+ has support for console events on Windows</span><span>
</span><span id="line-37"></span><span>  </span><span class="hs-comment">-- NOTE: running GHCi under a bash shell for some reason requires</span><span>
</span><span id="line-38"></span><span>  </span><span class="hs-comment">-- you to press Ctrl-Break rather than Ctrl-C to provoke</span><span>
</span><span id="line-39"></span><span>  </span><span class="hs-comment">-- an interrupt.  Ctrl-C is getting blocked somewhere, I don't know</span><span>
</span><span id="line-40"></span><span>  </span><span class="hs-comment">-- why --SDM 17/12/2004</span><span>
</span><span id="line-41"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679087898"><span class="annot"><span class="annottext">sig_handler :: ConsoleEvent -&gt; IO ()
</span><a href="#local-6989586621679087898"><span class="hs-identifier hs-var hs-var">sig_handler</span></a></span></span><span> </span><span class="annot"><span class="annottext">ConsoleEvent
</span><a href="../../base/src/GHC.Event.Windows.ConsoleEvent.html#ControlC"><span class="hs-identifier hs-var">ControlC</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679087904"><span class="hs-identifier hs-var">interrupt</span></a></span><span>
</span><span id="line-42"></span><span>      </span><span class="annot"><a href="#local-6989586621679087898"><span class="hs-identifier hs-var">sig_handler</span></a></span><span> </span><span class="annot"><span class="annottext">ConsoleEvent
</span><a href="../../base/src/GHC.Event.Windows.ConsoleEvent.html#Break"><span class="hs-identifier hs-var">Break</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679087904"><span class="hs-identifier hs-var">interrupt</span></a></span><span>
</span><span id="line-43"></span><span>      </span><span class="annot"><a href="#local-6989586621679087898"><span class="hs-identifier hs-var">sig_handler</span></a></span><span> </span><span class="annot"><span class="annottext">ConsoleEvent
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span>  </span><span class="annot"><span class="annottext">Handler
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handler -&gt; IO Handler
</span><a href="../../base/src/GHC.ConsoleHandler.html#installHandler"><span class="hs-identifier hs-var">installHandler</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ConsoleEvent -&gt; IO ()) -&gt; Handler
</span><a href="../../base/src/GHC.ConsoleHandler.html#Catch"><span class="hs-identifier hs-var">Catch</span></a></span><span> </span><span class="annot"><span class="annottext">ConsoleEvent -&gt; IO ()
</span><a href="#local-6989586621679087898"><span class="hs-identifier hs-var">sig_handler</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-48"></span></pre></body></html>